package com.lanou3g.zjl.chating.home.chatwindow.child;

import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;

import com.lanou3g.zjl.chating.R;
import com.lanou3g.zjl.chating.base.BaseFragment;
import com.lanou3g.zjl.chating.utils.DefaultEmojicon;
import com.lanou3g.zjl.chating.utils.EmojiconUtils;

import java.util.Arrays;
import java.util.List;

import butterknife.Bind;
import de.greenrobot.event.EventBus;

/**
 * Created by dllo on 15/11/30.
 */
public class NormalExpressionFragment extends BaseFragment {

    private NormalExpressionGvAdapter adapter;
    private List<EmojiconUtils> list;

    @Bind(R.id.normalExpressionGv)
    GridView normalExpressionGv;

    @Override
    protected View getLayout(LayoutInflater inflater) {
        return inflater.inflate(R.layout.fragment_normalexpression, null);
    }

    @Override
    protected void initData() {
        list = Arrays.asList(DefaultEmojicon.getData());

        adapter = new NormalExpressionGvAdapter();
        normalExpressionGv.setAdapter(adapter);
        adapter.addData(list);

        normalExpressionGv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//                String str = list.get(position).getEmojiText();
                String str;
                if (position < 10) {
                    str = "ee_0" + (position + 1);
                } else {
                    str = "ee_" + (position + 1);
                }
//                Log.d("NormalExpressionFragmen", str +"");
                Integer resId = list.get(position).getIcon();

                EventBus.getDefault().post(str);
                EventBus.getDefault().post(resId);

            }
        });
    }


}
